// 简化版启动器 - 当 Electron 安装失败时使用
const path = require('path');
const { spawn } = require('child_process');

console.log('正在尝试启动 Electron 应用...');

// 尝试不同的 Electron 路径
const electronPaths = [
  './node_modules/.bin/electron.cmd',
  './node_modules/.bin/electron',
  './node_modules/electron/dist/electron.exe',
  'electron'
];

function tryStartElectron(pathIndex = 0) {
  if (pathIndex >= electronPaths.length) {
    console.error('无法找到 Electron 可执行文件');
    console.log('请运行以下命令手动安装：');
    console.log('npm install electron@22.3.27 --save-dev');
    return;
  }

  const electronPath = electronPaths[pathIndex];
  console.log(`尝试路径: ${electronPath}`);

  const child = spawn(electronPath, ['.'], {
    stdio: 'inherit',
    shell: true
  });

  child.on('error', (err) => {
    console.log(`路径 ${electronPath} 失败，尝试下一个...`);
    tryStartElectron(pathIndex + 1);
  });

  child.on('exit', (code) => {
    if (code !== 0) {
      console.log(`Electron 退出，代码: ${code}`);
    }
  });
}

tryStartElectron();
